﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IP2Location;

namespace WebApplication4
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            IP2Location.IPResult oIPResult = new IP2Location.IPResult();
            IP2Location.Component oIPComponent = new IP2Location.Component();

            try
            {
                oIPComponent.IPDatabasePath = Server.MapPath("IP-COUNTRY.BIN");
                oIPResult = oIPComponent.IPQuery(TextBox1.Text);

                Response.Write("IP address: " + oIPResult.IPAddress + "<br/>");
                Response.Write("Country Name: " + oIPResult.CountryLong + "<br/>");
                Response.Write("Country Code: " + oIPResult.CountryShort + "<br/>");
                Response.Write("Region Name: " + oIPResult.Region + "<br/>");
                Response.Write("City Name: " + oIPResult.City + "<br/>");
                Response.Write("ZIP Code: " + oIPResult.ZipCode + "<br/>");
                Response.Write("Latitude: " + oIPResult.Latitude + "<br/>");
                Response.Write("Logitude: " + oIPResult.Longitude + "<br/>");
                Response.Write("Domain Name: " + oIPResult.DomainName + "<br/>");
                Response.Write("ISP Name: " + oIPResult.InternetServiceProvider + "<br/>");
                Response.Write("Time Zone: " + oIPResult.TimeZone + "<br/>");
                Response.Write("Net Speed: " + oIPResult.NetSpeed + "<br/>");
                Response.Write("IDD Code: " + oIPResult.IDDCode + "<br/>");
                Response.Write("Area Code: " + oIPResult.AreaCode + "<br/>");
                Response.Write("Weather Station Code: " + oIPResult.WeatherStationCode + "<br/>");
                Response.Write("Weather Station Name: " + oIPResult.WeatherStationName + "<br/>");
                Response.Write("MCC: " + oIPResult.MCC + "<br/>");
                Response.Write("MNC: " + oIPResult.MNC + "<br/>");
                Response.Write("Mobile Brand: " + oIPResult.MobileBrand + "<br/>");
                Response.Write("Elevation: " + oIPResult.Elevation + "<br/>");
                Response.Write("Usage Type: " + oIPResult.UsageType + "<br/>");
                
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
    }
}